﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Login : System.Web.UI.Page
{
    User user = new User();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (user.IsExist(txtUserName.Text))
        {
            if (user.UserLogin(txtUserName.Text, txtPwd.Text))
            {
                Session.Add("UserName", txtUserName.Text);
                Response.Redirect("TopicList.aspx");
            }
            else
            {
                Response.Write("<script language=javascript>alert('密码错误！')</script>");
            }
        }
        else
        {
            Response.Write("<script language=javascript>alert('不存在此用户名！')</script>");
        }
    }
    protected void btnGuest_Click(object sender, EventArgs e)
    {
        Session.Add("UserName","Guest");
        Response.Redirect("TopicList.aspx");
    }
}
